<?php
class User extends CI_Controller {

    public function __construct($value='')
    {
         parent::__construct();
         $this->load->helper(array('form', 'url'));
    }

    // index方法是默认方法
    public function index()
    {
        // $this->load->helper(array('form', 'url'));
        // echo '这是我的user控制器';
        // echo site_url('news/local/123');
        // echo base_url("blog/post/123");
        $this->load->view('login.html');        
    }

    public function check()
    {
        // $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('login.html');
        }
        else
        {
            $this->load->view('success.html');
        }
    }
    // 显示注册页面

    public function displayreg()
    {
        // $this->load->helper(array('form', 'url'));
        $this->load->view('reg.html');

    }

    // 用户注册
    public function reg()
    {
        // 开启调试模式
        $this->output->enable_profiler(TRUE);
        $this->load->database();

        // 检查用户输入的数据
        $this->load->library('form_validation');

        $this->form_validation->set_rules('email','email','trim|required|valid_email|is_unique[user.email]');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('reg.html');
        }
        else
        {
            // 存放到数据库

            // 跳转到登录页面
            $this->load->view('login.html');
        }
       
    }

}